package com.ctshk.sapp.bus.controller;

import com.ctshk.common.dto.Result;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.bus.dto.BusInitializationSettingsDTO;
import com.ctshk.rpc.bus.req.BusInitializationSettingsReq;
import com.ctshk.rpc.bus.service.IBusInitializationSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 巴士票api初始化设置表 前端控制器
 * </p>
 *
 * @author 彭柳霖
 * @since 2021-02-07
 */
@Api(value="资源中心-巴士API初始化设置", tags="资源中心-巴士API初始化设置")
@RestController
@RequestMapping("/bus-initialization-settings")
public class BusInitializationSettingsController extends BaseController {

    @DubboReference
    private IBusInitializationSettingsService initializationSettingsService;


    @ApiOperation(value = "巴士票api初始化设置", notes = "巴士票api初始化设置")
    @PostMapping(value = "/save")
    public Result<Void> saveSettingInfo(@RequestBody @Valid BusInitializationSettingsReq busInitializationSettingsReq) {
        TokenUser user = getCurrentUser(getRequest());
        return initializationSettingsService.saveSettingInfo(busInitializationSettingsReq,user);
    }

    @ApiOperation(value = "查询巴士票初始化默认API详情", notes = "查询巴士票初始化默认API详情")
    @GetMapping(value = "/detail")
    public Result<BusInitializationSettingsDTO> queryDetail(@RequestParam(value = "supplierId", required = true) Long supplierId) {
        return Result.success(initializationSettingsService.queryDetail(supplierId));
    }

}
